package co.fitstart.weapp.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.course.round.CourseRound;
import co.fitstart.entity.course.schedule.TargetData;
import co.fitstart.entity.user.StudentTargetData;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Dao("hibernate")
public interface StudentTargetDao {

    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM StudentTargetData WHERE disabled = false AND courseRound = :courseRound ORDER BY createTime DESC")
    public List<StudentTargetData> list(@Variable("courseRound") CourseRound courseRound);
    
    /**
     * 
     * @param courseRound
     * @return
     */
    @Query("FROM StudentTargetData WHERE disabled = false AND courseRound = :courseRound AND targetType IS NOT NULL ORDER BY createTime DESC")
    public StudentTargetData load(@Variable("courseRound") CourseRound courseRound);
    
    /**
     * 
     * @return
     */
    @Query("FROM TargetData")
    public TargetData load();

    /**
     * 
     * @param courseRounds
     * @return
     */
    @Query("SELECT target.courseRound FROM StudentTargetData target WHERE target.disabled = false AND target.courseRound IN (:courseRounds) AND target.targetType IS NOT NULL")
    public List<CourseRound> listCourseRound(@Variable("courseRounds") List<CourseRound> courseRounds);
}
